package com.project.service;

import com.project.dao.FeedbackMapper;
import com.project.entity.Feedback;
import com.project.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: TateBrown
 * @date: 2018/5/26 13:48
 * @param:
 * @return:
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class FeedBackServiceImpl extends BaseService implements FeedBackService{
    @Autowired
    private  FeedbackMapper feedbackMapper;

    /**
     * author: WheelChen
     * date: 2017/10/22
     * function: 添加单条记录
     *
     * @param feedback
     * @return
     */
    @Override
    public int addOne(Feedback feedback) {
        return feedbackMapper.insertSelective(feedback);
    }

    /**
     * author: WheelChen
     * date: 2017/10/22
     * function: 根据id删除单条记录
     *
     * @param id
     * @return
     */
    @Override
    public int removeOneById(Integer id) {
        return feedbackMapper.deleteByPrimaryKey(id);
    }

    /**
     * author: WheelChen
     * date: 2017/10/22
     * function: 根据id修改单条记录
     *
     * @param feedback
     * @return
     */
    @Override
    public int modifyOneById(Feedback feedback) {
        return feedbackMapper.updateByPrimaryKeySelective(feedback);
    }

    /**
     * author: WheelChen
     * date: 2017/10/22
     * function: 根据id查找单条记录
     *
     * @param id
     * @return
     */
    @Override
    public Feedback findOneById(Integer id) {
        return feedbackMapper.selectByPrimaryKey(id);
    }

    /**
     * author: WheelChen
     * date: 2017/10/22
     * function: 查找全部
     *
     * @return
     */
    @Override
    public List<Feedback> findAll() {
        return feedbackMapper.selectAll();
    }

    /**
     * author: WheelChen
     * date: 2017/10/24
     * function: 根据所有条件分页查找
     *
     * @param feedback
     * @return
     */
    @Override
    public List<Feedback> findBatchByAllCondition(Feedback feedback) {
        return feedbackMapper.selectByAllCondition(feedback);
    }
}
